package com.system.controller;

import com.common.annotation.MyLog;
import com.system.entity.Log;
import com.system.service.LogService;
import com.system.vo.request.LogPageReqVO;
import com.system.vo.response.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
import java.util.List;
import com.common.res.DataResult;


import javax.validation.Valid;
import java.util.List;

/**
* @author XueHeng
* @since 2020-09-17
*/
@RestController
@RequestMapping("api")
@Api(tags = "日志管理")
public class LogController {

    @Autowired
    private LogService logService;

    @PostMapping("/logs")
    @ApiOperation("日志列表")
    @MyLog(title = "日志管理",action = "获取日志列表")
    @RequiresPermissions("sys:log:list")
    public DataResult<PageVO<Log>> getAllDept(@RequestBody @Valid LogPageReqVO vo){
        DataResult result =DataResult.success();
        result.setData(this.logService.selectAll(vo));
        return result;
    }



    @DeleteMapping(value = "/log")
    @ApiOperation("删除日志")
    @MyLog(title = "日志管理",action = "删除日志")
    @RequiresPermissions("sys:log:delete")
    public DataResult remove(@RequestBody @Valid List<String> logIds) {
        DataResult result =DataResult.success();
        this.logService.delete(logIds);
        return result;
    }
}
